import { ObjCreate } from "../../common/ObjCreate";
import { EquipConfig } from "../../../resource/EquipConfig";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { GComboBox } from "../../../../../com/mui/controls/GComboBox";
import { ItemData } from "../../../resource/info/ItemData";
type int = number;
//class TargetRefreshSelectPanel
    
    export  class TargetRefreshSelectPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initUI();
            this.initData();
            return;
        }

        protected initUI(): void
        {
            this.cb1 = ObjCreate.createGComboBox(0, 0, 138, 26, null, this);
            this.cb2 = ObjCreate.createGComboBox(0, 30, 138, 26, null, this);
            this.cb3 = ObjCreate.createGComboBox(0, 60, 138, 26, null, this);
            this.cb4 = ObjCreate.createGComboBox(0, 90, 138, 26, null, this);
            return;
        }

        protected initData(): void
        {
            this.dataArr1 = EquipConfig.instance.getRefreshTargetCbData(1);
            this.dataArr2 = EquipConfig.instance.getRefreshTargetCbData(2);
            this.dataArr3 = EquipConfig.instance.getRefreshTargetCbData(3);
            this.dataArr4 = EquipConfig.instance.getRefreshTargetCbData(4);
            this.dataProvider1 = new DataProvider(this.dataArr1);
            this.dataProvider2 = new DataProvider(this.dataArr2);
            this.dataProvider3 = new DataProvider(this.dataArr3);
            this.dataProvider4 = new DataProvider(this.dataArr4);
            this.cb1.dataProvider = this.dataProvider1;
            this.cb2.dataProvider = this.dataProvider2;
            this.cb3.dataProvider = this.dataProvider3;
            this.cb4.dataProvider = this.dataProvider4;
            return;
        }

        public get expectAttr(): Map<any, any> /* flash.utils.Dictionary */
        {
            var loc2=null;
            var loc1=new Map<any, any> /* flash.utils.Dictionary */();
            var loc3=1;
            while (loc3 <= 4) 
            {
                loc2 = this["cb" + loc3] as GComboBox;
                if (loc2.selectedItem && loc2.selectedItem["type"] > 0) 
                {
                    loc1[loc2.selectedItem["type"]] = loc2.selectedItem["star"];
                }
                ++loc3;
            }
            return loc1;
        }

        public get expectAttrAll(): int
        {
            var loc2=null;
            var loc4=0;
            var loc1=0;
            var loc3=1;
            while (loc3 <= 4) 
            {
                loc2 = this["cb" + loc3] as GComboBox;
                if (loc2.selectedItem && loc2.selectedItem["type"] == 0) 
                {
                    loc4 = loc2.selectedItem["star"];
                    if (loc1 == 0 || loc1 > loc4) 
                    {
                        loc1 = loc4;
                    }
                }
                ++loc3;
            }
            return loc1;
        }

        public filterAttributes(arg1: ItemData): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            var loc6=1;
            while (loc6 <= 4) 
            {
                loc1 = this["dataProvider" + loc6] as DataProvider;
                loc2 = this["dataArr" + loc6] as Array<any>;
                loc5 = (loc3 = this["cb" + loc6] as GComboBox).selectedItem;
                loc1.removeAll();
                var loc7=0;
                var loc8=loc2;
                for(loc4 of loc8) 
                {
                    if (loc4.type > 0) 
                    {
                        if (EquipConfig.instance.checkHasRate(arg1, loc4.type)) 
                        {
                            loc1.addItem(loc4);
                        }
                        continue;
                    }
                    loc1.addItem(loc4);
                }
                loc3.dataProvider = loc1;
                if (loc1.getItemIndex(loc5) >= 0) 
                {
                    loc3.selectedItem = loc5;
                }
                ++loc6;
            }
            return;
        }

        /* internal */ /* var */dataArr1: Array<any>;

        /* internal */ /* var */dataArr2: Array<any>;

        /* internal */ /* var */dataArr3: Array<any>;

        /* internal */ /* var */dataArr4: Array<any>;

        /* internal */ /* var */dataProvider1: DataProvider;

        /* internal */ /* var */dataProvider2: DataProvider;

        /* internal */ /* var */dataProvider3: DataProvider;

        /* internal */ /* var */dataProvider4: DataProvider;

        /* internal */ /* var */cb1: GComboBox;

        /* internal */ /* var */cb2: GComboBox;

        /* internal */ /* var */cb3: GComboBox;

        /* internal */ /* var */cb4: GComboBox;
    }
